package g4.map;
import com.google.android.maps.OverlayItem;
import com.google.android.maps.GeoPoint;
import java.util.TreeMap;
//import android.os.Bundle;
import java.lang.Double;
import java.util.ArrayList;


public class CustomOverlayItem extends OverlayItem {

	private int id = 0;
	private int ikoni = 0;
	private String Image = "";
	private ArrayList<String> tags;
	private Boolean draw;
	//Suunta suunta;
	
	public CustomOverlayItem(GeoPoint point, String title, String snippet){	
		super(point, title, snippet);
		System.out.println("Overlayitemin konstruktorissa");
		this.draw = true;
	}
	
	public CustomOverlayItem(GeoPoint point, String title, String snippet, ArrayList<String> tagList) {
		super(point, title, snippet);
		this.tags = tagList;
		this.draw = true;
	}
	
	//Aika riski konstruktori, saa poistaa
	public CustomOverlayItem(TreeMap<String, String> in){
		
		super(new GeoPoint((int) (Double.parseDouble(in.get("lat")) * 1E6),(int) (Double.parseDouble(in.get("lng")) * 1E6)), in.get("caption"), in.get("value"));
	
	}
	
	public ArrayList<String> toArrayList(){
		
		ArrayList<String> temp = new ArrayList<String>();
		temp.add("Begin");
		temp.add("value:" + getSnippet());
		temp.add("caption:" + getTitle());
		temp.add("lat:" + new Double(getPoint().getLatitudeE6()) / 1E6);
		temp.add("lng:" + new Double(getPoint().getLongitudeE6()) / 1E6);
		temp.add("id:" + id);
		if(hasImage()) temp.add("img:" + Image);
		temp.add("End");
		return temp;
	}
	
	public int getIconId(){
		return ikoni;
	}
	
	public void setIconId(int in){
		ikoni = in;
	}
	
	public boolean hasImage(){
		return(!Image.equals(""));
	}
	
	public String getImageString(){
		return Image;
	}
	
	public void setImage(String Image_){
		Image = Image_;
	}
	
	//Tama ei ole konstruktorissa, koska yhteensopivuus
	public int getId(){
		return id;
	}

	public void setId(int id_){
		id = id_;
	}
	
	
	
	// Ei valttamatta tarvita, jos aina tehdaan vain setTags() kun muutetaan tageja
	public void addTag(String tag) {
		this.tags.add(tag);	
	}
	
	/**
	 * Set the tags for this CustomOverlayItem
	 * @param tags
	 */
	public void setTags(ArrayList<String> tags) {
		this.tags = tags;
	}
	
	public ArrayList<String> getTags() {
		return tags;
	}

	/**
	 * Sets whether point is drawn or not
	 * @param draw
	 */
	public void setDraw(Boolean draw) {
		this.draw = draw;
	}

	public Boolean getDraw() {
		return draw;
	}
	
	public String toString() {
		
		String temp;
		temp = "'" + this.getSnippet() + "',";
		temp += "'" + this.getTitle() + "',";
		GeoPoint tempPoint = this.getPoint();
		temp += "'" + (tempPoint.getLatitudeE6() / 1E6) + "',";
		temp += "'" + (tempPoint.getLongitudeE6() / 1E6) + "',";
		temp += "'";
		for (int i = 0; i < this.tags.size(); i++)
		{
			temp += this.tags.get(i) + ",";	
		}
		temp += "'";
		temp += "'" + this.getImageString() + "'" + "\n";
		
		return temp;		
	}
	
}